package cn.jcet.mapreduce.nline;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @author 鲜磊
 * @Date 2020/12/7 23:18
 */
public class NLineMapper extends Mapper<IntWritable,Text,Text,IntWritable> {

    private Text k = new Text();
    private IntWritable v = new IntWritable(1);

    @Override
    protected void map(IntWritable key, Text value, Context context) throws IOException, InterruptedException {
        String line = value.toString();

        String[] split = line.split(" ");
        for (String val : split) {
                k.set(val);
                context.write(k,v);
        }
    }
}
